home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 1.toast / Sample Code / Games / ISp Sample / Source / ErrorAlert.c < prev    next >
Encoding:
Text File  |  2000-09-28  |  2.3 KB  |  99 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        ErrorAlert.c
  3.  
  4.     Contains:    xxx put contents here xxx
  5.  
  6.     Version:    xxx put version here xxx
  7.  
  8.     Copyright:    © 1999 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     File Ownership:
  11.  
  12.         DRI:                xxx put dri here xxx
  13.  
  14.         Other Contact:        xxx put other contact here xxx
  15.  
  16.         Technology:            xxx put technology here xxx
  17.  
  18.     Writers:
  19.  
  20.         (BWS)    Brent Schorsch
  21.  
  22.     Change History (most recent first):
  23.  
  24.        <SP1>      7/1/99    BWS        first checked in
  25. */
  26.  
  27.  
  28. //•    ————————————————————————————————————————    Includes
  29.  
  30. #include <Dialogs.h>
  31. #include <Processes.h>
  32. #include <NumberFormatting.h>
  33. #include <TextUtils.h>
  34.  
  35. #include "ErrorAlert.h"
  36. #include "AppShellResources.h"
  37.  
  38.  
  39. //•    ————————————————————————————————————————    Private Definitions
  40. //•    ————————————————————————————————————————    Private Types
  41. //•    ————————————————————————————————————————    Private Variables
  42.  
  43. unsigned char gFatalErrOccuredStr[] = "\pA fatal error has occured (";
  44. unsigned char gErrOccuredStr[] = "\pAn error has occured (";
  45. unsigned char gEndParenStr[] = "\p)";
  46.  
  47. //•    ————————————————————————————————————————    Private Functions
  48. //•    ————————————————————————————————————————    Public Variables
  49.  
  50. //•    ————————————————————    AboutBox
  51.  
  52. void
  53. ErrorAlert(StringPtr errorStr, OSStatus errNum, Boolean shouldQuit)
  54. {
  55. Str255                    titleStr;
  56. Str31                    errorNumAsStr;
  57. SInt32                    length = 0;
  58. SInt16                    itemHit;
  59. AlertStdAlertParamRec    pb;
  60.     
  61.     //• set up the error string with the error number
  62.     NumToString (errNum, errorNumAsStr);
  63.     
  64.     if (shouldQuit)
  65.     {
  66.         BlockMoveData (&gFatalErrOccuredStr[1], &titleStr[1], gFatalErrOccuredStr[0]);
  67.         length = gFatalErrOccuredStr[0];
  68.     }
  69.     else
  70.     {
  71.         BlockMoveData (&gErrOccuredStr[1], &titleStr[1], gErrOccuredStr[0]);
  72.         length = gErrOccuredStr[0];
  73.     }
  74.     
  75.     BlockMoveData (&errorNumAsStr[1], &titleStr[1+length], errorNumAsStr[0]);
  76.     length += errorNumAsStr[0];
  77.  
  78.     BlockMoveData (&gEndParenStr[1], &titleStr[1+length], gEndParenStr[0]);
  79.     length += gEndParenStr[0];
  80.     
  81.     titleStr[0] = length;
  82.     
  83.     //• set up the pb for StandardAlert
  84.     pb.movable = false;
  85.     pb.helpButton = false;
  86.     pb.filterProc = nil;
  87.     pb.defaultText = (StringPtr) kAlertDefaultOKText;
  88.     pb.cancelText = nil;
  89.     pb.otherText = nil;
  90.     pb.defaultButton = kStdOkItemIndex;
  91.     pb.cancelButton = kStdCancelItemIndex;
  92.     pb.position = kWindowAlertPositionParentWindowScreen;
  93.  
  94.     StandardAlert(kAlertStopAlert, titleStr, errorStr, &pb, &itemHit);
  95.     
  96.     if (shouldQuit)
  97.         ExitToShell();
  98. }
  99.